return last inserted id in laravel

109

Get last id in laravel -

$last = DB::table('items')->latest()->first();

return last inserted id in laravel -

DB::getPdo()->lastInsertId();

return last inserted id in laravel -

$id = DB::table('users')->insertGetId([
    'email' => '[email protected]',
    'votes' => 0
]);

Comments

Submit
0 Comments